package com.zzptc.hjp;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.zzptc.hjp.databinding.ActivityRegBinding;

public class RegActivity extends AppCompatActivity {
    ActivityRegBinding binding;
    private static final String TAG = "RegActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_reg);
        event();
    }

    private void event() {
        binding.btnRegOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
             // Log.d(TAG,"你点击了我");
                //准备回传1.获取值 2.保存值到意图 3.回传
                String username =binding.etName1.getText().toString().trim();
                String password=binding.etPwd1.getText().toString().trim();
                if(username.equals("")||password.equals("")) {
                    Toast.makeText(RegActivity.this, "用户名或密码不能为空", Toast.LENGTH_SHORT).show();
                }
                Log.d(TAG,username);
                Intent intent=new Intent();
                intent.putExtra("uname",username);
                intent.putExtra("pwd",password);
                setResult(RESULT_OK,intent);
                finish();

            }
        });
    }
}
